home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWFrame.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  58.5 KB  |  1,918 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWFrame.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWFRAME_H
  13. #include "FWFrame.h"
  14. #endif
  15.  
  16. #ifndef FWFRMINF_H
  17. #include "FWFrmInf.h"
  18. #endif
  19.  
  20. #ifndef FWPART_H
  21. #include "FWPart.h"
  22. #endif
  23.  
  24. #ifndef FWEDCMD_H
  25. #include "FWEdCmd.h"
  26. #endif
  27.  
  28. #ifndef FWPRESEN_H
  29. #include "FWPresen.h"
  30. #endif
  31.  
  32. #ifndef FWSELECT_H
  33. #include "FWSelect.h"
  34. #endif
  35.  
  36. #ifndef FWITERS_H
  37. #include "FWIters.h"
  38. #endif
  39.  
  40. #ifndef FWGADGET_H
  41. #include "FWGadget.h"
  42. #endif
  43.  
  44. #ifndef FWUTIL_H
  45. #include "FWUtil.h"
  46. #endif
  47.  
  48. #ifndef FWCLNINF_H
  49. #include "FWClnInf.h"
  50. #endif
  51.  
  52. #ifndef FWCNTRHW_H
  53. #include "FWCntrHW.h"
  54. #endif
  55.  
  56. #ifndef FWVIEWAS_H
  57. #include "FWViewAs.h"
  58. #endif
  59.  
  60. #ifndef FWPRMISE_H
  61. #include "FWPrmise.h"
  62. #endif
  63.  
  64. #ifndef FWSCLNOT_H
  65. #include "FWSclNot.h"
  66. #endif
  67.  
  68. #ifndef FWPRHDLR_H
  69. #include "FWPrHdlr.h"
  70. #endif
  71.  
  72. // ----- OS Layer -----
  73.  
  74. #ifndef FWODMISS_H
  75. #include "FWODMiss.h"
  76. #endif
  77.  
  78. #ifndef FWEVENT_H
  79. #include "FWEvent.h"
  80. #endif
  81.  
  82. #ifndef FWEVENTU_H
  83. #include "FWEventU.h"
  84. #endif
  85.  
  86. #ifndef FWMNUBAR_H
  87. #include "FWMnuBar.h"
  88. #endif
  89.  
  90. #ifndef FWODGEOM_H
  91. #include "FWODGeom.h"
  92. #endif
  93.  
  94. #ifndef FWCURSOR_H
  95. #include "FWCursor.h"
  96. #endif
  97.  
  98. #ifndef FWBARRAY_H
  99. #include "FWBArray.h"
  100. #endif
  101.  
  102. #ifndef FWGRGLOB_H
  103. #include "FWGrGlob.h"
  104. #endif
  105.  
  106. #ifndef FWGDEV_H
  107. #include "FWGDev.h"
  108. #endif
  109.  
  110. #ifndef FWMACOS_H
  111. #include "FWMacOS.h"
  112. #endif
  113.  
  114. #ifndef FWWINDOW_H
  115. #include "FWWindow.h"
  116. #endif
  117.  
  118. #if !defined(FWGRMATH_H) && defined(FW_BUILD_WIN)
  119. #include "FWGrMarh.h"
  120. #endif
  121.  
  122. // ----- OpenDoc Includes -----
  123.  
  124. #ifndef SOM_ODSession_xh
  125. #include <ODSessn.xh>
  126. #endif
  127.  
  128. #ifndef SOM_ODArbitrator_xh
  129. #include <Arbitrat.xh>
  130. #endif
  131.  
  132. #ifndef SOM_Module_OpenDoc_Commands_defined
  133. #include <CmdDefs.xh>
  134. #endif
  135.  
  136. #ifndef SOM_ODStorageUnitView_xh
  137. #include <SUView.xh>
  138. #endif
  139.  
  140. #ifndef SOM_ODClipboard_xh
  141. #include <Clipbd.xh>
  142. #endif
  143.  
  144. #ifndef SOM_Module_OpenDoc_StdProps_defined
  145. #include <StdProps.xh>
  146. #endif
  147.  
  148. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  149. #include <StdTypes.xh>
  150. #endif
  151.  
  152. //========================================================================================
  153. // RunTime Info
  154. //========================================================================================
  155.  
  156. #if FW_LIB_EXPORT_PRAGMAS
  157. #pragma lib_export on
  158. #endif
  159.  
  160. #ifdef FW_BUILD_MAC
  161. #pragma segment FW_FrameSegment
  162. #endif
  163.  
  164. FW_DEFINE_CLASS_M3(FW_CFrame, FW_CView, FW_MDragDroppable, FW_MIdle);
  165.  
  166. //========================================================================================
  167. //    class FW_CFrame
  168. //========================================================================================
  169.  
  170. //----------------------------------------------------------------------------------------
  171. //    FW_CFrame::FW_CFrame
  172. //----------------------------------------------------------------------------------------
  173.  
  174. FW_CFrame::FW_CFrame(Environment *ev,
  175.                     ODFrame* odFrame, 
  176.                     FW_CPresentation* presentation, 
  177.                     FW_CPart* part) :
  178.     FW_MDragDroppable(ev, part),
  179.     FW_CView(ev),        
  180.     FW_MIdle(part, this),
  181.     fPart(part),
  182.     fContentView(NULL),
  183.     fGetFrontClicks(TRUE),
  184.     fActiveFacet(NULL),
  185.     fCanBeActiveFrame(TRUE),
  186.     fFocusSet(ev, part->GetSession(ev)),
  187.     fChangedFocusSet(ev, part->GetSession(ev)),
  188.     fFocusSetChanged(FALSE),
  189.     fNeedsFoci(FALSE),
  190.     fPresentation(presentation),
  191.     fWindow(NULL),
  192.     fFacetCount(0),
  193.     fODFrame(odFrame),
  194.     fPreviousViewType(odFrame->GetViewType(ev)),
  195.     fViewAs(NULL),
  196.     fConnection(NULL),
  197.     fViewUnderCursor(NULL),
  198.     fScrollingViews(NULL),
  199.     fContentViewLocation(FW_kZeroPoint)
  200. #ifdef FW_BUILD_WIN
  201.     ,fShadowWindow(NULL)
  202. #endif
  203. {
  204.     FW_ASSERT(fODFrame);
  205.     
  206.     fTarget = this;
  207.     
  208.     this->SetNextEventHandler(ev, part);
  209.  
  210.     fNeedsFoci = odFrame->IsRoot(ev);
  211.     
  212.     // ----- By default we put all of them
  213.     // Note: If the containing window is a floating window I will remove
  214.     // them in facet added.
  215.     fFocusSet.Add(ev, FW_CPart::gKeyFocusToken);
  216.     fFocusSet.Add(ev, FW_CPart::gMenuFocusToken);
  217.     fFocusSet.Add(ev, FW_CPart::gSelectionFocusToken);
  218.     fFocusSet.Add(ev, FW_CPart::gClipboardFocusToken);
  219.             
  220.     SetIdentifier(ev, fPresentation->GetPresentationType(ev));
  221.     
  222.     // ----- force to be view as frame if root -----
  223.     if (fPreviousViewType != FW_CPart::gViewAsFrameToken && IsRoot(ev))
  224.         fODFrame->SetViewType(ev, FW_CPart::gViewAsFrameToken);
  225.  
  226.     // ----- Set the frame's view Bounds to its shape bounds
  227.     FW_CRect frameRect;
  228.     PrivGetFrameShapeBounds(ev, frameRect);
  229.     PrivSetBounds(ev, frameRect);
  230.     PrivSetExtent(ev, frameRect.Size());    
  231.  
  232.     // ----- By default the frame is equal to its ContentView
  233.     PrivSetIsContentView(ev, TRUE);
  234.     fContentView = (FW_CView*)this;
  235. }
  236.  
  237. //----------------------------------------------------------------------------------------
  238. //    FW_CFrame::~FW_CFrame
  239. //----------------------------------------------------------------------------------------
  240.  
  241. FW_CFrame::~FW_CFrame()
  242. {
  243.     Environment* ev = somGetGlobalEnvironment();
  244.     
  245.     FW_ASSERT(IsRegisteredForIdle(ev) == FALSE);
  246.  
  247.     FW_ASSERT(fWindow == NULL);    // should have been deleted in FrameRemoved
  248.     
  249.     if (fViewAs && fPresentation)
  250.         fPresentation->ReleaseViewAs(ev, fViewAs);
  251.  
  252.     if (fConnection) {
  253.         fConnection->RemoveAllInterests();    // [LSD] necessary?
  254.         delete fConnection;
  255.         fConnection = NULL;
  256.     }
  257.     
  258.     // deletes its ContentView first to make sure that the scroller is deleted before
  259.     // the scrollbars (otherwise ~FW_CView deletes views in reverse order of creation)
  260.     if (IsContentView(ev) == FALSE)    {
  261.         delete GetContentView(ev);
  262.     }
  263.     
  264.     if (fScrollingViews) {
  265.         delete fScrollingViews;
  266.         fScrollingViews = NULL;
  267.     }
  268. }
  269.  
  270. //----------------------------------------------------------------------------------------
  271. //    FW_CFrame::PrivCreateWindow
  272. //----------------------------------------------------------------------------------------
  273.  
  274. FW_CWindow* FW_CFrame::PrivCreateWindow(Environment* ev, ODWindow* odWindow)
  275. {
  276.     FW_ASSERT(odWindow);
  277.     FW_ASSERT(fWindow == NULL || fWindow->GetID(ev) == odWindow->GetID(ev));
  278.     
  279.     if (fWindow == NULL)
  280.     {
  281.         ODPlatformWindow platformWindow = odWindow->GetPlatformWindow(ev);
  282.         
  283.         FW_CWindow* fwWindow = NULL;
  284.         
  285.         if (IsRoot(ev))
  286.         {
  287. #ifdef FW_BUILD_MAC
  288.             fwWindow = (FW_CWindow*) ::GetWRefCon(platformWindow);
  289. #endif
  290.  
  291. #ifdef FW_BUILD_WIN
  292.             fwWindow = (FW_CWindow*) ::GetProp(platformWindow, "ODF:Window");
  293. #endif
  294.         }
  295.         
  296.         if (fwWindow != NULL)
  297.             fWindow = fwWindow;
  298.         else
  299.             fWindow = new FW_CWindow(ev, fPart->GetODPart(ev), odWindow->GetID(ev));
  300.     }
  301.  
  302.     return fWindow;
  303. }
  304.  
  305. //----------------------------------------------------------------------------------------
  306. //    FW_CFrame::FrameRemoved
  307. //----------------------------------------------------------------------------------------
  308. // Notification
  309.  
  310. void FW_CFrame::FrameRemoved(Environment* ev, FW_Boolean toStorage)
  311. {
  312. FW_UNUSED(toStorage);
  313.  
  314.     if (toStorage)
  315.         UnregisterIdle(ev);
  316.         
  317.     // ----- Relinquish what ever focus we have
  318.     fFocusSet.RelinquishFocusSet(ev, GetODFrame(ev));
  319.         
  320.     // ----- Check that the window has been deleted -----
  321.     FW_ASSERT(fFacetCount == 0);    
  322.     FW_ASSERT(fWindow == NULL);    // When the frame is removed it should not have any facets. fWindow
  323.                                 // should already be null (see FacetRemoved)
  324.  
  325.     // ----- delete the partInfo -----
  326.     FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)fODFrame->GetPartInfo(ev);
  327.     fODFrame->SetPartInfo(ev, NULL);
  328.     delete framePartInfo;
  329.  
  330.     fPresentation->PrivRemoveFrame(ev, this);
  331. }
  332.  
  333. //----------------------------------------------------------------------------------------
  334. //    FW_CFrame::FrameAdded
  335. //----------------------------------------------------------------------------------------
  336. // Notification
  337.  
  338. void FW_CFrame::FrameAdded(Environment* ev, FW_Boolean fromStorage)
  339. {
  340. FW_UNUSED(ev);
  341. FW_UNUSED(fromStorage);
  342.     
  343.     // ----- Add it to the presentation -----
  344.     fPresentation->PrivAddFrame(ev, this);
  345.     
  346.     // ----- Initialize printing handler -----
  347.     FW_CPrintHandler* printHandler = NewPrintHandler(ev);
  348.     if (printHandler != NULL)
  349.         AdoptEventHandler(ev, printHandler);
  350. }
  351.  
  352. //----------------------------------------------------------------------------------------
  353. //    FW_CFrame::PageEmbeddedFrames
  354. //----------------------------------------------------------------------------------------
  355.  
  356. void FW_CFrame::PageEmbeddedFrames(Environment* ev)
  357. {
  358.     // Doesn't do anything because not embedding
  359. }
  360.  
  361. //----------------------------------------------------------------------------------------
  362. //    FW_CFrame::GetODStorageUnitID
  363. //----------------------------------------------------------------------------------------
  364.  
  365. ODStorageUnitID FW_CFrame::GetODStorageUnitID(Environment* ev) const
  366. {
  367.     ODStorageUnit* storageUnit = fODFrame->GetStorageUnit(ev);
  368.     
  369.     return storageUnit != NULL ? storageUnit->GetID(ev) : kODNULLID;
  370. }
  371.  
  372. //----------------------------------------------------------------------------------------
  373. // FW_CFrame::GetTarget
  374. //----------------------------------------------------------------------------------------
  375.  
  376. FW_MEventHandler* FW_CFrame::GetTarget(Environment* ev) const
  377. {
  378.     return fTarget;
  379. }
  380.  
  381. //----------------------------------------------------------------------------------------
  382. // FW_CFrame::SetTarget
  383. //----------------------------------------------------------------------------------------
  384.  
  385. void FW_CFrame::SetTarget(Environment* ev, FW_MEventHandler* theTarget)
  386. {
  387.     fTarget = theTarget;
  388. }
  389.  
  390. //----------------------------------------------------------------------------------------
  391. // FW_CFrame::WantsToBeTarget
  392. //----------------------------------------------------------------------------------------
  393.  
  394. FW_Boolean FW_CFrame::WantsToBeTarget(Environment* ev)
  395. {
  396.     return TRUE;
  397. }
  398.  
  399. //----------------------------------------------------------------------------------------
  400. //    FW_CFrame::HandleMenu
  401. //----------------------------------------------------------------------------------------
  402.  
  403. FW_Boolean FW_CFrame::HandleMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
  404. {
  405.     FW_Boolean result = TRUE;
  406.     FW_CEditCommand* cmd;
  407.     ODCommandID commandID = theMenuEvent.GetCommandID(ev);
  408.     
  409.     switch (commandID)
  410.     {
  411.         case kODCommandViewAsWin:
  412.             fPresentation->ViewInWindow(ev, this, NULL);
  413.             break;
  414.         
  415.         case kODCommandCut:
  416.         case kODCommandCopy:
  417.         case kODCommandPaste:
  418.         case kODCommandPasteAs:
  419.         case kODCommandClear:
  420.             cmd = this->NewEditCommand(ev, commandID);
  421.             if (cmd)
  422.                 GetPart(ev)->ExecuteCommand(ev, cmd);
  423.             break;
  424.                         
  425.         case kODCommandSelectAll:
  426.             FW_CSelection* selection = fPresentation->GetSelection(ev);
  427.             if (selection)
  428.                 selection->SelectAll(ev);
  429.             break;
  430.             
  431.         default:
  432.             result = FW_CView::HandleMenu(ev, theMenuEvent);    
  433.     }
  434.     
  435.     return result;
  436. }
  437.  
  438. //----------------------------------------------------------------------------------------
  439. //    FW_CFrame::SetDragging
  440. //----------------------------------------------------------------------------------------
  441.  
  442. void FW_CFrame::SetDragging(Environment* ev, FW_Boolean dragging)
  443. {
  444.     fODFrame->SetDragging(ev, dragging);
  445. }
  446.  
  447. //----------------------------------------------------------------------------------------
  448. //    FW_CFrame::SetDroppable
  449. //----------------------------------------------------------------------------------------
  450.  
  451. void FW_CFrame::SetDroppable(Environment* ev, FW_Boolean droppable)
  452. {
  453.     fODFrame->SetDroppable(ev, droppable);
  454. }
  455.  
  456. //----------------------------------------------------------------------------------------
  457. //    FW_CFrame::NewPartWindow
  458. //----------------------------------------------------------------------------------------
  459.  
  460. FW_CWindow* FW_CFrame::NewPartWindow(Environment* ev, ODFacet* sourceFacet)
  461. {
  462.     FW_CRect frameBounds = GetBounds(ev);
  463.     FW_CAcquiredODTransform transform = sourceFacet->AcquireWindowFrameTransform(ev, NULL);
  464.     frameBounds.Transform(ev, transform);
  465.     GetWindow(ev)->WindowToScreen(ev, frameBounds);
  466.     frameBounds.Offset(FW_IntToFixed(20), FW_IntToFixed(20));
  467.     
  468.     FW_CString255 partName;
  469.     fPart->GetPartName(ev, partName);
  470.     
  471.     return new FW_CWindow(ev, 
  472.                         fPart->GetODPart(ev),
  473.                         fODFrame,
  474.                         FALSE,                            // persistent frame
  475.                         FW_CPart::gViewAsFrameToken,
  476.                         GetPresentation(ev)->GetPresentationType(ev),
  477.                         partName,
  478.                         frameBounds.Size(),
  479.                         frameBounds.TopLeft(),
  480.                         FW_kDocumentWindow);
  481. }
  482.  
  483. //----------------------------------------------------------------------------------------
  484. //    FW_CFrame::NewEditCommand
  485. //----------------------------------------------------------------------------------------
  486.  
  487. FW_CEditCommand* FW_CFrame::NewEditCommand(Environment* ev, ODCommandID commandID)
  488. {
  489.     return FW_NEW(FW_CEditCommand, (ev,
  490.                                     commandID,
  491.                                     this,
  492.                                     FW_kCantUndo));
  493. }
  494.  
  495. //----------------------------------------------------------------------------------------
  496. //    FW_CFrame::InstallMenus
  497. //----------------------------------------------------------------------------------------
  498. //     By default call the part with a null menuBar
  499.  
  500. void FW_CFrame::InstallMenus(Environment *ev)
  501. {
  502.     GetPart(ev)->InstallMenus(ev, NULL);    // will install the part menubar
  503. }
  504.  
  505. #ifdef FW_BUILD_MAC
  506. //----------------------------------------------------------------------------------------
  507. //    FW_CFrame::HandleWindowEvent
  508. //----------------------------------------------------------------------------------------
  509.  
  510. FW_Boolean FW_CFrame::HandleWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent)
  511. {
  512.     FW_Boolean handled = TRUE;
  513.     
  514.     unsigned long message = windowEvent.GetMessage();
  515.     switch (windowEvent.GetMessage())
  516.     {
  517.         case inZoomIn:
  518.         case inZoomOut:
  519.             {    
  520.                 ODPlatformWindow platformWindow = GetWindow(ev)->GetPlatformWindow(ev);
  521.                 
  522.                 // ----- Get the size of the window border -----
  523.                 FW_CRect borderSize;
  524.                 FW_CWindow::PrivGetBorderSize(platformWindow, borderSize);
  525.                 
  526.                 // ----- Find out where the window would like to be zoomed out to 
  527.                 FW_CRect screenRect;
  528.                 ::FW_MacGetMaxIntersectedDevice(platformWindow, screenRect);
  529.                 screenRect.Inset(FW_IntToFixed(3), FW_IntToFixed(3));    // leave space around window structure area
  530.             
  531.                 // ----- call the part to get a custom size (interior size) -----
  532.                 FW_CPoint proposedSize(screenRect.Width() - borderSize.left - borderSize.right, 
  533.                                        screenRect.Height() - borderSize.top - borderSize.bottom);
  534.                 this->AdjustZoomedWindowSize(ev, proposedSize);
  535.                 
  536.                 fWindow->PrivMacDoZoom(ev, proposedSize, borderSize, screenRect, message);
  537.             }
  538.             break;
  539.         
  540.         case inGrow:
  541.             {
  542.                 FW_CRect growLimits(FW_IntToFixed(64), FW_IntToFixed(64), FW_IntToFixed(32000), FW_IntToFixed(32000));
  543.                 this->AdjustWindowGrowLimits(ev, growLimits[FW_kTopLeft], growLimits[FW_kBotRight]);
  544.                 
  545.                 // If minimum is lareger than maximun then do something
  546.                 if (growLimits.left > growLimits.right)
  547.                     growLimits.left = growLimits.right;
  548.                 if (growLimits.top > growLimits.bottom)
  549.                     growLimits.top = growLimits.bottom;
  550.                     
  551.                 fWindow->PrivMacTrackResizeWindow(ev, growLimits, windowEvent);
  552.             }
  553.             break;
  554.  
  555.         case inGoAway:
  556.              if (fWindow->IsFloating(ev)) 
  557.                 fWindow->Hide(ev);
  558.             else
  559.                 handled = FALSE;
  560.             break;
  561.             
  562.         default:
  563.             handled = FALSE;
  564.     }
  565.     
  566.     return handled;
  567. }
  568. #endif
  569.  
  570. //----------------------------------------------------------------------------------------
  571. // FW_CFrame::AdjustZoomedWindowSize
  572. //----------------------------------------------------------------------------------------
  573. //    proposedSize is the interior size of the window
  574.  
  575. void FW_CFrame::AdjustZoomedWindowSize(Environment *ev, FW_CPoint& proposedSize)
  576. {
  577. }
  578.  
  579. //----------------------------------------------------------------------------------------
  580. // FW_CFrame::AdjustWindowGrowLimits
  581. //----------------------------------------------------------------------------------------
  582. //    proposedSize is the interior size of the window
  583.  
  584. void FW_CFrame::AdjustWindowGrowLimits(Environment *ev, FW_CPoint& minSize, FW_CPoint& maxSize)
  585. {
  586. }
  587.  
  588. //----------------------------------------------------------------------------------------
  589. //    FW_CFrame::HandleAdjustMenus
  590. //----------------------------------------------------------------------------------------
  591.  
  592. FW_Boolean FW_CFrame::HandleAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, 
  593.                                     FW_Boolean hasMenuFocus, FW_Boolean isRoot)
  594. {
  595.     if (hasMenuFocus)
  596.     {
  597.         // ----- Only if I am the target -----
  598.         if (GetTarget(ev) == this)
  599.         {
  600.             FW_CSelection* selection = fPresentation->GetSelection(ev);
  601.             FW_Boolean hasSelection = selection && !selection->IsEmpty(ev);
  602.         
  603.             // ----- Edit Menu -----
  604.             // If read only clear, cut past items will be disabled in FW_CPart::HandleAdjustMenus
  605.             menuBar->EnableCommand(ev, kODCommandClear, hasSelection);
  606.             menuBar->EnableCommand(ev, kODCommandCut, hasSelection);
  607.             menuBar->EnableCommand(ev, kODCommandCopy, hasSelection);
  608.             menuBar->EnableCommand(ev, kODCommandPaste, FALSE);
  609.             
  610.             menuBar->EnableCommand(ev, kODCommandPasteAs, HasPropertyOnClipboard(ev, kODPropLinkSpec, kODLinkSpec));
  611.         }
  612.         
  613.         menuBar->EnableCommand(ev, kODCommandViewAsWin, !IsTopFrame(ev));
  614.     }
  615.     
  616.     return FW_CView::HandleAdjustMenus(ev, menuBar, hasMenuFocus, isRoot);
  617. }
  618.  
  619. //----------------------------------------------------------------------------------------
  620. //    FW_CFrame::IsTopFrame
  621. //----------------------------------------------------------------------------------------
  622. //    IsTopFrame returns true if this frame is a sub-frame of the root frame
  623.  
  624. FW_Boolean FW_CFrame::IsTopFrame(Environment *ev) const
  625. {
  626.     if (IsRoot(ev))
  627.         return TRUE;
  628.     
  629.     return IsSubframe(ev) && AcquireContainingFrame(ev)->IsRoot(ev);
  630. }
  631.  
  632. //----------------------------------------------------------------------------------------
  633. //    FW_CFrame::IsSiblingFrameOf
  634. //----------------------------------------------------------------------------------------
  635.  
  636. FW_Boolean FW_CFrame::IsSiblingFrameOf(Environment *ev, ODFrame* otherODFrame) const
  637. {
  638.     if (otherODFrame == NULL)
  639.         return FALSE;
  640.         
  641.     FW_CAcquiredODPart otherPart = otherODFrame->AcquirePart(ev);
  642.     if (GetODPart(ev) == otherPart)
  643.     {
  644.         FW_CFrame* otherFrame = FW_CFrame::ODtoFWFrame(ev, otherODFrame);
  645.         return GetPresentation(ev) == otherFrame->GetPresentation(ev);
  646.     }
  647.     
  648.     return FALSE;
  649. }
  650.  
  651. //----------------------------------------------------------------------------------------
  652. //    FW_CFrame::FocusStateChanged
  653. //----------------------------------------------------------------------------------------
  654. //    When overridden, call inherited::FocusStateChanged FIRST
  655.  
  656. void FW_CFrame::FocusStateChanged(Environment *ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
  657. {
  658.     if (focus == FW_CPart::gSelectionFocusToken)
  659.     {
  660.         if (!newState)
  661.         {
  662. /*    [HLX] we have a bug in ODF. If I close the selection when I get deactivated I can't clear it anymore
  663. during a drag&drop. The dropped frame actives itself before I have time to clear the selection
  664.             //     Close the selection if I become deactive and the newOwner is not NULL and
  665.             //    not one of my sibling
  666.             FW_CSelection* selection = fPresentation->GetSelection(ev);
  667.             if (selection)
  668.             {
  669.                 if (newOwner != NULL && !IsSiblingFrameOf(ev, newOwner))
  670.                     selection->CloseSelection(ev);
  671.             }
  672. */
  673.             Deactivate(ev);
  674.         }
  675.         else
  676.         {
  677.             Activate(ev);
  678.         }
  679.         
  680.         fPart->SetActiveFrame(ev, newState ? this : NULL);
  681.     }
  682.     else if (focus == FW_CPart::gMenuFocusToken)
  683.     {
  684.         if (newState)
  685.         {
  686.             InstallMenus(ev);
  687.             fPart->HideShowFloatingWindows(ev, TRUE);
  688.         }
  689.     }
  690. }
  691.  
  692. //----------------------------------------------------------------------------------------
  693. //     FW_CFrame::Activate
  694. //----------------------------------------------------------------------------------------
  695.  
  696. FW_Boolean FW_CFrame::Activate(Environment* ev)
  697. {
  698.     FW_Boolean result = FW_CView::Activate(ev);
  699.     
  700.     // *LSD this part to review: which SubView should become target.
  701.     //  Should have saved a target at the last deactivate.
  702.     if (result && this->IsEnabled(ev) && this->WantsToBeTarget(ev))
  703.         this->BecomeTarget(ev);
  704.     
  705.     return result;
  706. }
  707.  
  708. //----------------------------------------------------------------------------------------
  709. //     FW_CFrame::ActivateFrame
  710. //----------------------------------------------------------------------------------------
  711.  
  712. void FW_CFrame::ActivateFrame(Environment *ev, ODFacet* activatedFacet)
  713.     if (CanBeActiveFrame(ev))
  714.     {
  715.         SetActiveFacet(ev, activatedFacet);
  716.         
  717.         if (!IsActive(ev))
  718.         {
  719.             // ----- Check first if the FocusSet has been changed -----
  720.             if (fFocusSetChanged)
  721.             {
  722.                 fFocusSet = fChangedFocusSet;
  723.                 fFocusSetChanged = FALSE;
  724.             }
  725.             
  726.             // ----- Our version of RequestFocusSet returns false if the focus set is empty
  727.             if (fFocusSet.RequestFocusSet(ev, GetODFrame(ev)))
  728.             {
  729.                 fNeedsFoci = FALSE;
  730.                 
  731.                 FW_CFocusSetIterator ite(ev, fFocusSet);
  732.                 for (ODTypeToken token = ite.First(ev); ite.IsNotComplete(ev); token = ite.Next(ev))
  733.                     FocusStateChanged(ev, token, TRUE, NULL);            
  734.             }
  735.         }
  736.     }
  737. }
  738.  
  739. //----------------------------------------------------------------------------------------
  740. //    FW_CFrame::CanBeActiveFrame
  741. //----------------------------------------------------------------------------------------
  742.  
  743. FW_Boolean FW_CFrame::CanBeActiveFrame(Environment* ev) const
  744. {
  745.     FW_ASSERT(GetWindow(ev) != NULL);
  746.     return fCanBeActiveFrame && !GetWindow(ev)->IsFloating(ev);
  747. }
  748.  
  749. //----------------------------------------------------------------------------------------
  750. //    FW_CFrame::PrivGetFrameShapeBounds
  751. //----------------------------------------------------------------------------------------
  752.  
  753. void FW_CFrame::PrivGetFrameShapeBounds(Environment* ev, FW_CRect& rect) const
  754. {
  755.     FW_CAcquiredODShape aqODShape = AcquireFrameShape(ev, NULL);
  756.     rect = FW_GetShapeBoundingBox(ev, aqODShape);
  757. }
  758.  
  759. //----------------------------------------------------------------------------------------
  760. //    FW_CFrame::ODtoFWFrame
  761. //----------------------------------------------------------------------------------------
  762.  
  763. FW_CFrame* FW_CFrame::ODtoFWFrame(Environment *ev, ODFrame* odFrame)
  764. {
  765.     FW_CFrame* frame = NULL;
  766.     
  767.     if (odFrame)
  768.     {
  769.         FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)odFrame->GetPartInfo(ev);
  770.         FW_ASSERT(framePartInfo != NULL);
  771.         frame = framePartInfo->GetFrame();
  772.     }
  773.     
  774.     return frame;
  775. }
  776.  
  777. //----------------------------------------------------------------------------------------
  778. //     FW_CFrame::FrameShapeChanged
  779. //----------------------------------------------------------------------------------------
  780. //    When overridden, call inherited::FrameShapeChanged
  781.  
  782. void FW_CFrame::FrameShapeChanged(Environment* ev)
  783. {
  784.     FW_CRect frameRect;
  785.     PrivGetFrameShapeBounds(ev, frameRect);
  786.     SetSize(ev, frameRect.Size());
  787.     SetExtent(ev, frameRect.Size());  // *LSD: ok?
  788.     
  789.     if (GetViewType(ev) == FW_CPart::gViewAsFrameToken)
  790.     {
  791. #ifdef FW_BUILD_WIN
  792.         MoveSizeShadowWindow(ev);
  793. #endif
  794.         AdjustSubViews(ev);
  795.     }
  796.     
  797.     UpdateUsedAndActiveShapes(ev);
  798. }
  799.  
  800. //----------------------------------------------------------------------------------------
  801. //    FW_CFrame::SetActiveFacet
  802. //----------------------------------------------------------------------------------------
  803.  
  804. void FW_CFrame::SetActiveFacet(Environment* ev, ODFacet*  activeFacet)
  805. {
  806.     fActiveFacet = activeFacet;
  807. }
  808.  
  809. //----------------------------------------------------------------------------------------
  810. //    FW_CFrame::UpdateUsedAndActiveShapes
  811. //----------------------------------------------------------------------------------------
  812.  
  813. void FW_CFrame::UpdateUsedAndActiveShapes(Environment* ev)
  814. {
  815.     // ----- Used Shape -----
  816.     UpdateUsedShape(ev);
  817.  
  818.     // ----- Active Shape for everyone of my facets -----
  819.     FW_CFrameFacetIterator iter(ev, this);
  820.     for (ODFacet* facet = iter.First(ev); iter.IsNotComplete(ev); facet = iter.Next(ev))
  821.     {
  822.         UpdateActiveShape(ev, facet);
  823.     }
  824. }
  825.  
  826. //----------------------------------------------------------------------------------------
  827. //    FW_CFrame::UpdateUsedShape
  828. //----------------------------------------------------------------------------------------
  829.  
  830. void FW_CFrame::UpdateUsedShape(Environment* ev)
  831. {
  832.     // ----- Used Shape -----
  833.     FW_CAcquiredODShape aqUsedShape;
  834.     
  835.     if (fViewAs == NULL)
  836.     {
  837.         //    ----- By default the used shape is the frame shape
  838.         FW_CAcquiredODShape aqFrameShape = FW_CopyAndRelease(ev, AcquireFrameShape(ev, NULL));
  839.         aqUsedShape = AdjustUsedShape(ev, aqFrameShape);
  840.     }
  841.     else
  842.     {
  843.         aqUsedShape = fViewAs->CalcUsedShape(ev);            
  844.     }
  845.     
  846.     ChangeUsedShape(ev, aqUsedShape, NULL);    // Passing NULL is valid
  847. }
  848.  
  849. //----------------------------------------------------------------------------------------
  850. //    FW_CFrame::UpdateActiveShape
  851. //----------------------------------------------------------------------------------------
  852.  
  853. void FW_CFrame::UpdateActiveShape(Environment* ev, ODFacet* facet)
  854. {
  855.     FW_CAcquiredODShape aqActiveShape;
  856.     FW_CAcquiredODShape aqProposedActiveShape = FW_CopyAndRelease(ev, AcquireUsedShape(ev));
  857.     
  858.     if (fViewAs == NULL) 
  859.         aqActiveShape = AdjustActiveShape(ev, facet, aqProposedActiveShape);
  860.     else
  861.         aqActiveShape = aqProposedActiveShape;
  862.         
  863.     facet->ChangeActiveShape(ev, aqActiveShape, NULL);    
  864. }
  865.  
  866. //----------------------------------------------------------------------------------------
  867. //    FW_CFrame::AdjustUsedShape
  868. //----------------------------------------------------------------------------------------
  869. //    suggestedUsedShape is the frame shape. The default implementation returns NULL because
  870. //    we don't want to maintain an used shape
  871.  
  872. ODShape* FW_CFrame::AdjustUsedShape(Environment* ev, ODShape* suggestedUsedShape)
  873. {
  874.     return NULL;
  875. }
  876.  
  877. //----------------------------------------------------------------------------------------
  878. //    FW_CFrame::AdjustActiveShape
  879. //----------------------------------------------------------------------------------------
  880. //    suggestedActiveShape is the used shape. The default implementation returns NULL because
  881. //    we don't want to maintain an active shape
  882.  
  883. ODShape* FW_CFrame::AdjustActiveShape(Environment* ev, ODFacet* facet, ODShape* suggestedActiveShape)
  884. {
  885.     return NULL;
  886. }
  887.  
  888. //----------------------------------------------------------------------------------------
  889. //    FW_CFrame::SetFocusSet
  890. //----------------------------------------------------------------------------------------
  891. // We have to use a temporary focusSet because if the focus set is changed while the frame 
  892. // is active and relinquishFocus is called (like in FrameRemoved) it will be called 
  893. // with the wrong focus set
  894.  
  895. void FW_CFrame::SetFocusSet(Environment* ev, const FW_CFocusSet& focusSet)
  896. {
  897.     fFocusSetChanged = TRUE;
  898.     fChangedFocusSet = focusSet;
  899.     
  900.     // ----- [HLX] bug in OpenDoc ???
  901.     if (IsRoot(ev))
  902.     {
  903.         if (!fChangedFocusSet.Contains(ev, FW_CPart::gSelectionFocusToken))
  904.             fChangedFocusSet.Add(ev, FW_CPart::gSelectionFocusToken);
  905.     }
  906. }
  907.  
  908. //----------------------------------------------------------------------------------------
  909. //     FW_CFrame::FacetPartInfoFactory
  910. //----------------------------------------------------------------------------------------
  911.  
  912. FW_CFacetPartInfo* FW_CFrame::FacetPartInfoFactory(Environment* ev, ODFacet* facet)
  913. {
  914.     FW_CFacetPartInfo* facetPartInfo = new FW_CFacetPartInfo;
  915.     facetPartInfo->InitFacetPartInfo(ev, facet);
  916.     return facetPartInfo;
  917. }
  918.  
  919. //----------------------------------------------------------------------------------------
  920. //    FW_CFrame::RequestFrameShape
  921. //----------------------------------------------------------------------------------------
  922.  
  923. FW_Boolean FW_CFrame::RequestFrameShape(Environment *ev, ODShape* shape, ODCanvas* biasCanvas)
  924. {
  925.     FW_CAcquiredODShape aqOldFrameShape = FW_CopyAndRelease(ev, AcquireFrameShape(ev, biasCanvas));
  926.     
  927.     FW_CAcquiredODShape aqNewFrameShape = fODFrame->RequestFrameShape(ev, shape, biasCanvas);
  928.     
  929.     FW_Boolean changed = !aqNewFrameShape->IsSameAs(ev, aqOldFrameShape);
  930.     
  931.     if (changed)
  932.         FrameShapeChanged(ev); 
  933.     
  934.     return changed;
  935. }
  936.  
  937. //----------------------------------------------------------------------------------------
  938. //     FW_CFrame::FacetAdded
  939. //----------------------------------------------------------------------------------------
  940. //    When overridden call inherited::FacetAdded FIRST
  941.  
  942. void FW_CFrame::FacetAdded(Environment* ev, ODFacet* facet)
  943. {        
  944.     // ----- Install the newest facet as the active facet of this frame
  945.     this->SetActiveFacet(ev, facet);
  946.     
  947.     // ----- Set the facet's part info -----
  948.     FW_CFacetPartInfo *facetInfo = FacetPartInfoFactory(ev, facet);
  949.     facet->SetPartInfo(ev, (ODInfoType)facetInfo);
  950.  
  951.     // ----- Create the window wrapper -----
  952.     // ----- We have to wait for facet added because 
  953.     // ----- at FrameAdded it it too early
  954.     FW_CAcquiredODWindow aqODWindow = fODFrame->AcquireWindow(ev);
  955.     this->PrivCreateWindow(ev, aqODWindow);    // Might not create a FW_CWindow if already has one    
  956.  
  957.     // ----- If the Window is a floating window: remove all the foci by
  958.     // ------ setting an empty set.
  959.     if (aqODWindow->IsFloating(ev))
  960.     {
  961.         FW_CFocusSet focusSet(ev, fPart->GetSession(ev));
  962.         SetFocusSet(ev, focusSet);    
  963.     }
  964.     
  965.     // ----- Create the Shadow Window for Windows
  966. #ifdef FW_BUILD_WIN
  967.     CreateShadowWindow(ev);
  968. #endif    
  969.  
  970.     // ----- First facet: update used shape and create the sub-views
  971.     if(fFacetCount == 0)
  972.     {
  973.         UpdateUsedShape(ev);
  974.         
  975.         //FW_CGadgetInitializer vi(ev);    *LSD  replace it with CViewInitializer?
  976.         CreateSubViews(ev);
  977.     }
  978.  
  979.     // ----- Give my frame a chance to update the active shape of the facet -----
  980.     UpdateActiveShape(ev, facet);
  981.     
  982.     // ----- One more facet -----
  983.     fFacetCount++;
  984.     
  985.     // ----- Finally invalidate the content of the facet so it will be redrawn -----
  986.     FW_CAcquiredODShape aqUsedShape = AcquireUsedShape(ev); 
  987.     facet->Invalidate(ev, aqUsedShape, NULL);
  988. }
  989.  
  990. //----------------------------------------------------------------------------------------
  991. //     FW_CFrame::FacetRemoved
  992. //----------------------------------------------------------------------------------------
  993. //    When overridden call inherited::FacetRemoved last
  994.  
  995. void FW_CFrame::FacetRemoved(Environment* ev, ODFacet* odFacet)
  996. {
  997.     FW_ASSERT(fFacetCount > 0);
  998.     
  999.     if (this->GetActiveFacet(ev) == odFacet)
  1000.     {
  1001.         FW_CFrameFacetIterator iter(ev, this);
  1002.         this->SetActiveFacet(ev, iter.First(ev));
  1003.     }
  1004.     
  1005.     // ----- Delete the facet part info -----
  1006.     FW_CFacetPartInfo* partInfo = FW_CFacetPartInfo::GetFacetPartInfo(ev, odFacet);
  1007.     delete partInfo;
  1008.     odFacet->SetPartInfo(ev, (ODInfoType)NULL);
  1009.     
  1010.     // ----- One less facet -----
  1011.     fFacetCount--;
  1012.     
  1013.     // ----- Delete the fWindow if it was the last facet -----
  1014.     if (fFacetCount == 0)
  1015.     {
  1016.         FW_ASSERT(fWindow);
  1017.         delete fWindow;
  1018.         fWindow = NULL;
  1019.     }
  1020. }
  1021.  
  1022. //----------------------------------------------------------------------------------------
  1023. //    FW_CFrame::GetWindow
  1024. //----------------------------------------------------------------------------------------
  1025.  
  1026. FW_CWindow* FW_CFrame::GetWindow(Environment* ev) const
  1027. {
  1028.     return fWindow;
  1029. }
  1030.  
  1031. //----------------------------------------------------------------------------------------
  1032. //    FW_CFrame::PrivAttachSourceFrame
  1033. //----------------------------------------------------------------------------------------
  1034. // PrivAttachSourceFrame is not called if 'sourceFrame' is NULL
  1035.  
  1036. void FW_CFrame::PrivAttachSourceFrame(Environment* ev, FW_CFrame* sourceFrame)
  1037. {
  1038. FW_UNUSED(sourceFrame);
  1039.     
  1040.     FW_ASSERT(sourceFrame != NULL);    
  1041.     FW_ASSERT(fPresentation == sourceFrame->GetPresentation(ev));
  1042. }
  1043.  
  1044. //----------------------------------------------------------------------------------------
  1045. //    FW_CFrame::HasSelectionFocus()
  1046. //----------------------------------------------------------------------------------------
  1047.  
  1048. FW_Boolean FW_CFrame::HasSelectionFocus(Environment* ev) const
  1049. {    
  1050.     FW_CAcquiredODFrame aqODFrame = fPart->GetSession(ev)->GetArbitrator(ev)->AcquireFocusOwner(ev, FW_CPart::gSelectionFocusToken);
  1051.     return fODFrame == aqODFrame;
  1052. }
  1053.  
  1054. //----------------------------------------------------------------------------------------
  1055. //    FW_CFrame::ViewTypeChanged
  1056. //----------------------------------------------------------------------------------------
  1057.  
  1058. void FW_CFrame::ViewTypeChanged(Environment* ev, 
  1059.                                 ODTypeToken newViewType, 
  1060.                                 ODTypeToken oldViewType)
  1061. {
  1062.     Invalidate(ev);
  1063.     
  1064.     if (fViewAs != NULL)
  1065.         fPresentation->ReleaseViewAs(ev, fViewAs);
  1066.     fViewAs = NULL;
  1067.     
  1068.     if (newViewType != FW_CPart::gViewAsFrameToken)
  1069.         fViewAs = fPresentation->AcquireViewAs(ev, this, newViewType);
  1070.         
  1071.     UpdateUsedAndActiveShapes(ev);
  1072.     
  1073.     Invalidate(ev);
  1074. }
  1075.  
  1076. //----------------------------------------------------------------------------------------
  1077. //    FW_CFrame::BuildThumbnail
  1078. //----------------------------------------------------------------------------------------
  1079. //    By default does nothing
  1080.  
  1081. void FW_CFrame::BuildThumbnail(Environment* ev, FW_CGraphicContext& gc, const FW_CRect& destRect)
  1082. {
  1083. }
  1084.  
  1085. //----------------------------------------------------------------------------------------
  1086. //    FW_CFrame::PresentationChanged()
  1087. //----------------------------------------------------------------------------------------
  1088.  
  1089. void FW_CFrame::PresentationChanged(Environment* ev)
  1090. {    
  1091. //    SetIdentifier(ev, GetPresentation(ev));
  1092. }
  1093.  
  1094. //----------------------------------------------------------------------------------------
  1095. //    FW_CFrame::SequenceChanged()
  1096. //----------------------------------------------------------------------------------------
  1097.  
  1098. void FW_CFrame::SequenceChanged(Environment* ev)
  1099. {    
  1100. }
  1101.  
  1102. //----------------------------------------------------------------------------------------
  1103. //     FW_CFrame::PrivActiveWindowOnMouseDown
  1104. //----------------------------------------------------------------------------------------
  1105.  
  1106. FW_Boolean FW_CFrame::PrivActiveWindowOnMouseDown(Environment* ev, ODFacet* facet, FW_Boolean clickedInFrame)
  1107. {
  1108.     if (!GetWindow(ev)->IsFloating(ev))
  1109.     {
  1110.         FW_Boolean windowUnselected = !GetWindow(ev)->IsActive(ev);
  1111.         
  1112.         // ----- Select the window if not already selected -----
  1113.         if (windowUnselected)
  1114.             GetWindow(ev)->Select(ev);        
  1115.         
  1116.         // ----- active frame on mousedown only if clicked in the frame -----
  1117.         if (clickedInFrame)
  1118.             ActivateFrame(ev, facet);
  1119.         
  1120.         // ----- If the window was unselected and I don't want the ----- 
  1121.         // ----- first click just return TRUE;
  1122.         if (windowUnselected && !GetFrontClicks(ev))
  1123.                 return TRUE;
  1124.     }
  1125.     
  1126.     return FALSE;
  1127. }
  1128.  
  1129. //----------------------------------------------------------------------------------------
  1130. //    FW_CFrame::HandleActivateEvent
  1131. //----------------------------------------------------------------------------------------
  1132.  
  1133. FW_Boolean FW_CFrame::HandleActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
  1134. {
  1135.     if (theActivateEvent.IsActivating(ev))
  1136.     {
  1137.         if (fNeedsFoci) 
  1138.             ActivateFrame(ev, theActivateEvent.GetFacet(ev));
  1139.     }
  1140.     else
  1141.     {
  1142.         fNeedsFoci = IsActive(ev);
  1143.     }
  1144.     
  1145.     return FW_CView::HandleActivateEvent(ev, theActivateEvent);
  1146. }
  1147.  
  1148. //----------------------------------------------------------------------------------------
  1149. //    FW_CFrame::HandleSuspendResumeEvent
  1150. //----------------------------------------------------------------------------------------
  1151.  
  1152. FW_Boolean FW_CFrame::HandleSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theResumeSuspendEvent)
  1153. {
  1154.     if (IsRoot(ev))
  1155.     {
  1156.         // ----- We have to test that this frame belongs to the part with the menu focus
  1157.         ODArbitrator* arbitrator =  fPart->GetSession(ev)->GetArbitrator(ev);
  1158.         FW_CAcquiredODFrame aqODFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::gMenuFocusToken);
  1159.  
  1160.         if (aqODFrame != NULL)
  1161.         {
  1162.             FW_CAcquiredODPart aqODPart = aqODFrame->AcquirePart(ev);
  1163.             if (aqODPart == fPart->GetODPart(ev))
  1164.                 // ----- Won't do anything if window is not a floating window -----
  1165.                 GetWindow(ev)->HideShowOnActivate(ev, !theResumeSuspendEvent.IsGoingToBackground(ev));            
  1166.         }
  1167.         
  1168.     }
  1169.     
  1170.     return FW_CView::HandleSuspendResumeEvent(ev, theResumeSuspendEvent);
  1171. }
  1172.  
  1173. //----------------------------------------------------------------------------------------
  1174. //    FW_CFrame::GeometryChanged
  1175. //----------------------------------------------------------------------------------------
  1176. //    the geometry (clip shape or external transform) of one of my facet or one of my
  1177. //    embedding facet as changed
  1178.  
  1179. void FW_CFrame::GeometryChanged(Environment *ev,
  1180.                                 ODFacet* odFacet,
  1181.                                 FW_Boolean clipShapeChanged,
  1182.                                 FW_Boolean externalTransformChanged)
  1183. {
  1184. FW_UNUSED(ev);
  1185. FW_UNUSED(odFacet);
  1186. FW_UNUSED(clipShapeChanged);
  1187. FW_UNUSED(externalTransformChanged);
  1188.  
  1189. #ifdef FW_BUILD_WIN
  1190.     MoveSizeShadowWindow(ev);
  1191. #endif
  1192. }
  1193.  
  1194. //----------------------------------------------------------------------------------------
  1195. //    FW_CFrame::OpenSelection
  1196. //----------------------------------------------------------------------------------------
  1197.  
  1198. void FW_CFrame::OpenSelection(Environment* ev)
  1199. {
  1200.     // Nothing to do
  1201. }
  1202.  
  1203. //----------------------------------------------------------------------------------------
  1204. //    FW_CFrame::HandleDraw
  1205. //----------------------------------------------------------------------------------------
  1206.  
  1207. void FW_CFrame::HandleDraw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
  1208. {
  1209.     //     if the facet doesn't have a graphicdevice it is not one of my facet anymore
  1210.     //    That means that FacetRemoved has been called but my container is still trying
  1211.     //    do draw me.[HLX] Might be a bug in OpenDoc. Might have been fixed in DR4
  1212.     if (FW_CFacetPartInfo::GetFacetGraphicDevice(ev, odFacet) == NULL)
  1213.         return;
  1214.         
  1215. //    FW_CAcquiredODShape aqInvalidShape(invalidShape->Copy(ev));
  1216.  
  1217. //    // InvalidShape is in frame coordinate. Tranform it to content coordinate
  1218. //    FW_CAcquiredODTransform aqTransform = AcquireInternalTransform(ev, NULL);    
  1219. //    aqInvalidShape->InverseTransform(ev, aqTransform);
  1220.  
  1221. #ifdef FW_BUILD_WIN
  1222.     // [HLX] bug in windows? the invalidShape is in pixels instead of points
  1223.     aqInvalidShape->Outset(ev, ff(1));    // [HLX] Because of rounding errors
  1224.     FW_CGraphicDevice *device = FW_CFacetPartInfo::GetFacetGraphicDevice(ev, odFacet);
  1225.     device->PixelToPoint(ev, aqInvalidShape);
  1226. #endif
  1227.     
  1228.     // ATTENTION: we don't test fViewAs != NULL because if the frame was created
  1229.     //    as an icon or thumbnail it may not yet have a fViewAs
  1230.     ODTypeToken viewType = GetViewType(ev);
  1231.     if (viewType == FW_CPart::gViewAsFrameToken)
  1232.     {
  1233.         FW_CView::HandleDraw(ev, odFacet, invalidShape);
  1234.     }
  1235.     else
  1236.     {
  1237.         if (fViewAs == NULL)
  1238.             fViewAs = fPresentation->AcquireViewAs(ev, this, viewType);
  1239.                 
  1240.         fViewAs->Draw(ev, odFacet, invalidShape /*aqInvalidShape*/);
  1241.     }
  1242. }
  1243.  
  1244. //----------------------------------------------------------------------------------------
  1245. //    FW_CFrame::Draw
  1246. //----------------------------------------------------------------------------------------
  1247. // invalidShape is in content coordinate
  1248.  
  1249. void FW_CFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
  1250. {
  1251. FW_UNUSED(odFacet);
  1252. FW_UNUSED(invalidShape);
  1253.  
  1254. }
  1255.  
  1256. //----------------------------------------------------------------------------------------
  1257. //    FW_CFrame::HandleMouseEnter
  1258. //----------------------------------------------------------------------------------------
  1259. // where is in frame coordinate
  1260.  
  1261. FW_Boolean FW_CFrame::HandleMouseEnter(Environment *ev, ODFacet* odFacet, const FW_CPoint& where)
  1262. {
  1263.     fViewUnderCursor = GetViewContaining(ev, odFacet, where);
  1264.     FW_ASSERT(fViewUnderCursor != NULL);
  1265.  
  1266.     if (!fViewUnderCursor->AdjustCursor(ev, odFacet, where))
  1267.         FW_gArrowCursor.Select();
  1268.  
  1269.     return fViewUnderCursor->DoMouseEnter(ev, odFacet, where);
  1270. }
  1271.  
  1272. //----------------------------------------------------------------------------------------
  1273. //    FW_CFrame::HandleMouseLeave
  1274. //----------------------------------------------------------------------------------------
  1275.  
  1276. FW_Boolean FW_CFrame::HandleMouseLeave(Environment *ev, ODFacet* odFacet)
  1277. {
  1278.     FW_gArrowCursor.Select();
  1279.     
  1280.     FW_ASSERT(fViewUnderCursor != NULL);
  1281.     
  1282.     FW_Boolean result = fViewUnderCursor->DoMouseLeave(ev, odFacet);
  1283.  
  1284.     fViewUnderCursor = NULL;
  1285.     
  1286.     return result;
  1287. }
  1288.  
  1289. //----------------------------------------------------------------------------------------
  1290. //    FW_CFrame::HandleMouseWithin
  1291. //----------------------------------------------------------------------------------------
  1292. // where is in frame coordinate
  1293.  
  1294. FW_Boolean FW_CFrame::HandleMouseWithin(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint)
  1295. {
  1296.     FW_CView* viewUnderCursor = GetViewContaining(ev, odFacet, theMousePoint);
  1297.     FW_ASSERT(viewUnderCursor != NULL);
  1298.     
  1299.     FW_ASSERT(fViewUnderCursor != NULL);
  1300.     
  1301.     if (viewUnderCursor != fViewUnderCursor)
  1302.     {
  1303.         fViewUnderCursor->DoMouseLeave(ev, odFacet);
  1304.         
  1305.         viewUnderCursor->DoMouseEnter(ev, odFacet, theMousePoint);
  1306.     }
  1307.     else
  1308.         viewUnderCursor->DoMouseWithin(ev, odFacet, theMousePoint);
  1309.         
  1310.     fViewUnderCursor = viewUnderCursor;
  1311.     
  1312.     if (!fViewUnderCursor->AdjustCursor(ev, odFacet, theMousePoint))
  1313.         FW_gArrowCursor.Select();
  1314.         
  1315.     return TRUE;
  1316. }
  1317.  
  1318. //----------------------------------------------------------------------------------------
  1319. //    FW_CFrame::AdjustCursor
  1320. //----------------------------------------------------------------------------------------
  1321. // where is in frame coordinate
  1322.  
  1323. FW_Boolean FW_CFrame::AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint)
  1324. {
  1325.     return FALSE;
  1326. }
  1327.  
  1328. //----------------------------------------------------------------------------------------
  1329. //    FW_CFrame::GetODPart()
  1330. //----------------------------------------------------------------------------------------
  1331.  
  1332. ODPart* FW_CFrame::GetODPart(Environment* ev) const
  1333. {
  1334.     return fPart->GetODPart(ev);
  1335. }
  1336.  
  1337. //----------------------------------------------------------------------------------------
  1338. //    FW_CFrame::ExternalizeFrame
  1339. //----------------------------------------------------------------------------------------
  1340. // When overriding call inherited first
  1341.  
  1342. void FW_CFrame::ExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
  1343. {
  1344.     FW_CByteArray byteArray(&fContentViewLocation, sizeof(FW_CPoint));
  1345.     storageUnitView->SetValue(ev, byteArray);
  1346. }
  1347.  
  1348. //----------------------------------------------------------------------------------------
  1349. //    FW_CFrame::InternalizeFrame
  1350. //----------------------------------------------------------------------------------------
  1351. // When overriding call inherited first
  1352.  
  1353. void FW_CFrame::InternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
  1354. {
  1355.     FW_CByteArray byteArray;
  1356.     storageUnitView->GetValue(ev, sizeof(FW_CPoint), byteArray);
  1357.     byteArray.CopyBuffer(&fContentViewLocation, sizeof(FW_CPoint));
  1358. }
  1359.  
  1360. //----------------------------------------------------------------------------------------
  1361. //    FW_CFrame::SetContentView()
  1362. //----------------------------------------------------------------------------------------
  1363.  
  1364. void FW_CFrame::SetContentView(Environment* ev, FW_CView* view) 
  1365. {
  1366.     // SetContentView can only be called once to set fContentView
  1367.     // (fContentView was initialized to the frame itself)
  1368.     FW_ASSERT(IsContentView(ev) == TRUE);
  1369.     
  1370.     PrivSetIsContentView(ev, FALSE);
  1371.     fContentView = view;
  1372.  
  1373.     // Move the internal transform to be relative to the new ContentView
  1374.     FW_CAcquiredODTransform aqTransform = AcquireInternalTransform(ev, NULL);
  1375.     
  1376.     // ----- Remove the previous position -----
  1377.     FW_CPoint offset = -fContentViewLocation; 
  1378.     aqTransform->MoveBy(ev, (ODPoint*)&offset);
  1379.      
  1380.     FW_CAcquiredODTransform aqViewToFrameTransform(view->AcquireViewToFrameTransform(ev));
  1381.     aqTransform->PostCompose(ev, aqViewToFrameTransform);    
  1382.     
  1383.     ChangeInternalTransform(ev, aqTransform);
  1384.     
  1385.     PrivContentViewLocationChanged(ev);
  1386. }
  1387.  
  1388. //----------------------------------------------------------------------------------------
  1389. //    FW_CFrame::GetContentExtent
  1390. //----------------------------------------------------------------------------------------
  1391.  
  1392. void FW_CFrame::GetContentExtent(Environment* ev, FW_CPoint& extent) const
  1393. {
  1394.     extent = GetContentView(ev)->GetExtent(ev);
  1395. }
  1396.  
  1397. //----------------------------------------------------------------------------------------
  1398. //    FW_CFrame::AcquireContentShape
  1399. //----------------------------------------------------------------------------------------
  1400. //    return the content shape in Frame coordinates
  1401.  
  1402. ODShape* FW_CFrame::AcquireContentShape(Environment *ev)
  1403. {    
  1404.     FW_CView* contentView = GetContentView(ev);
  1405.     
  1406.     FW_CRect contentRect(contentView->GetBounds(ev));
  1407.     contentRect.Place(FW_kFixed0, FW_kFixed0);
  1408.     
  1409.     contentView->ViewToFrame(ev, contentRect);
  1410.     return FW_NewODShape(ev, contentRect);
  1411. }
  1412.  
  1413. //----------------------------------------------------------------------------------------
  1414. // FW_CFrame::AddScrollingView
  1415. //----------------------------------------------------------------------------------------
  1416.  
  1417. void FW_CFrame::AddScrollingView(Environment* ev, const FW_CView *view)
  1418. {
  1419.     FW_ASSERT(view->UseContentSpaceInX(ev) || view->UseContentSpaceInY(ev));
  1420.     
  1421.     if (fScrollingViews == NULL) {
  1422.         fScrollingViews = new FW_CPrivOrderedCollection;
  1423.     } 
  1424.     else {
  1425.         FW_ASSERT(fScrollingViews->Contains(this) == FALSE);    
  1426.     }
  1427.     
  1428.     fScrollingViews->AddLast((FW_CView*) view);
  1429. }
  1430.  
  1431. //----------------------------------------------------------------------------------------
  1432. // FW_CFrame::RemoveScrollingView
  1433. //----------------------------------------------------------------------------------------
  1434.  
  1435. void FW_CFrame::RemoveScrollingView(Environment* ev, const FW_CView *view)
  1436. {
  1437.     // fScrollingViews is already NULL when frame is being deleted
  1438.     if(fScrollingViews != NULL) {
  1439.         FW_ASSERT(fScrollingViews->Contains((FW_CView*)view));
  1440.         fScrollingViews->Remove((FW_CView*)view);
  1441.     }
  1442. }
  1443.  
  1444. //----------------------------------------------------------------------------------------
  1445. // FW_CFrame::AcquireContentScrollShape
  1446. //----------------------------------------------------------------------------------------
  1447. // This returns the shape (in Frame coord.) composed of the ContentView + all the views
  1448. // scrolling in X or Y with the content.  
  1449. // [LSD] if scroll is not purely X or Y we limit the shape to the ContentView for now.
  1450. //         Other views will have to scroll independantly
  1451.  
  1452. ODShape* FW_CFrame::AcquireContentScrollShape(Environment* ev, const FW_CPoint& by)
  1453. {
  1454.     // Get the contentView first
  1455.     ODShape* scrollShape = ::FW_NewODShape(ev, FW_CRect(FW_kZeroPoint, fContentView->GetSize(ev)));
  1456.     fContentView->ViewToFrame(ev, scrollShape);
  1457.  
  1458.     if (by.IntX() == 0 || by.IntY() == 0) {
  1459.         FW_Boolean verticalScroll = (by.IntX() == 0);
  1460.         FW_CScrollingViewIterator ite(ev, this);
  1461.         for (FW_CView* subview = ite.First(ev); ite.IsNotComplete(ev);  subview = ite.Next(ev))
  1462.         {
  1463.             if (subview->IsVisible(ev))
  1464.             {
  1465.                 if ((verticalScroll && subview->UseContentSpaceInX(ev)) ||
  1466.                     (!verticalScroll && subview->UseContentSpaceInY(ev))) continue;
  1467.                 
  1468.                 FW_CAcquiredODShape aqScrollShape = ::FW_NewODShape(ev, FW_CRect(FW_kZeroPoint, subview->GetSize(ev)));
  1469.                 subview->ViewToFrame(ev, aqScrollShape);
  1470.                 
  1471.                 scrollShape->Union(ev, aqScrollShape);
  1472.             }
  1473.         }
  1474.     }    
  1475.     
  1476.     return scrollShape;
  1477. }
  1478.  
  1479. //----------------------------------------------------------------------------------------
  1480. //    FW_CFrame::PrivReleaseODFrame
  1481. //----------------------------------------------------------------------------------------
  1482.  
  1483. void FW_CFrame::PrivReleaseODFrame(Environment *ev)
  1484. {
  1485.     FW_ASSERT(fODFrame != NULL);
  1486.     fODFrame->Release(ev);
  1487.     fODFrame = NULL;
  1488. }
  1489.  
  1490. //----------------------------------------------------------------------------------------
  1491. //    FW_CFrame::BeginRelinquishFocus
  1492. //----------------------------------------------------------------------------------------
  1493.  
  1494. FW_Boolean FW_CFrame::BeginRelinquishFocus(Environment *ev, ODTypeToken focus, ODFrame* proposedFrame)
  1495. {
  1496.     return TRUE;
  1497. }
  1498.  
  1499. //----------------------------------------------------------------------------------------
  1500. //    FW_CFrame::AbortRelinquishFocus
  1501. //----------------------------------------------------------------------------------------
  1502.  
  1503. void FW_CFrame::AbortRelinquishFocus(Environment *ev, ODTypeToken focus, ODFrame* proposedFrame)
  1504. {
  1505. }
  1506.  
  1507. //---------------------------------------------------------------------------------------
  1508. //    FW_CFrame::CommitRelinquishFocus
  1509. //---------------------------------------------------------------------------------------
  1510.  
  1511. void FW_CFrame::CommitRelinquishFocus(Environment *ev,
  1512.                                         ODTypeToken focus,
  1513.                                         ODFrame* proposedFrame)
  1514. {
  1515.     FocusStateChanged(ev, focus, FALSE, proposedFrame);
  1516.         
  1517.     FW_Boolean doIt = (proposedFrame == NULL);
  1518.     if (!doIt)
  1519.     {
  1520.         FW_CAcquiredODPart aqODPart = proposedFrame->AcquirePart(ev);
  1521.         doIt = aqODPart != fPart->GetODPart(ev);
  1522.     }
  1523.     
  1524.     if (doIt)
  1525.     {    
  1526.         if (focus == FW_CPart::gMenuFocusToken)
  1527.             fPart->HideShowFloatingWindows(ev, FALSE);
  1528.     }
  1529. }
  1530.  
  1531. //----------------------------------------------------------------------------------------
  1532. //    FW_CFrame::ClonePartInfo
  1533. //----------------------------------------------------------------------------------------
  1534.  
  1535. void FW_CFrame::ClonePartInfo(Environment* ev, 
  1536.                             ODDraftKey key,
  1537.                             ODInfoType partInfo,
  1538.                             ODStorageUnitView* storageUnitView,
  1539.                             ODFrame* scope)
  1540. {
  1541.     // Don't do anything for now
  1542. }
  1543.  
  1544. //----------------------------------------------------------------------------------------
  1545. //    FW_CFrame::AddConnection
  1546. //----------------------------------------------------------------------------------------
  1547.  
  1548. void FW_CFrame::AddConnection(Environment*ev, FW_CInterest& interest)
  1549. {
  1550.     if (fConnection == NULL) {
  1551.         fConnection = new FW_CHandleFunctionConnection(this);
  1552.         fConnection->Connect();
  1553.     }
  1554.     
  1555.     fConnection->AddInterest(interest);
  1556. }
  1557.  
  1558. //----------------------------------------------------------------------------------------
  1559. //    FW_CFrame::HandleNotification
  1560. //----------------------------------------------------------------------------------------
  1561.  
  1562. void FW_CFrame::HandleNotification(const FW_CNotification& notification)
  1563. {
  1564.     // *LSD: check that we're dealing only with scrolling
  1565.     Environment *ev = somGetGlobalEnvironment();
  1566.     ODSession* session = GetFrame(ev)->GetPart(ev)->GetSession(ev);
  1567.     ODTypeToken scrollNotificationToken = session->Tokenize(ev, FW_CScrollNotification::kName);
  1568.     
  1569.     if (notification.GetName() != scrollNotificationToken) {
  1570.         return;
  1571.     }
  1572.     
  1573.     const FW_CScrollNotification& scrollNfy = (FW_CScrollNotification&) notification;
  1574.     
  1575.     // Set scrollBy to opposite value of scrolling to move the internal transform
  1576.     FW_CPoint scrollBy;
  1577.     
  1578.     if (scrollNfy.GetDirection() == FW_CScrollNotification::kVertical)
  1579.         scrollBy.Set(FW_kFixed0, -scrollNfy.GetDelta());
  1580.     else
  1581.         scrollBy.Set(-scrollNfy.GetDelta(), FW_kFixed0);
  1582.     
  1583.     FW_CAcquiredODTransform aqTransform = AcquireInternalTransform(ev, NULL);
  1584.     ODPoint odScrollBy = scrollBy;
  1585.     aqTransform->MoveBy(ev, &odScrollBy);
  1586.  
  1587.     // *LSD2  hack can be removed after DR4 ?
  1588. #ifdef FW_BUILD_MAC
  1589.     // [HLX] Temporary because of a bug in OpenDoc
  1590.     //    ChangeInternalTransform changes the clip and the origin and does not restore it
  1591.     GrafPtr port;
  1592.     ::GetPort(&port);    
  1593.     Point origin;
  1594.     origin.h = port->portRect.left;
  1595.     origin.v = port->portRect.top;
  1596.     ODRgnHandle clipRgn = ::NewRgn();
  1597.     ::GetClip(clipRgn);
  1598. #endif
  1599.  
  1600.     ChangeInternalTransform(ev, aqTransform);
  1601.     
  1602. #ifdef FW_BUILD_MAC
  1603.     // [HLX] Temporary because of a bug in OpenDoc
  1604.     ::SetPort(port);
  1605.     ::SetClip(clipRgn);
  1606.     ::DisposeRgn(clipRgn);
  1607.     ::SetOrigin(-origin.h, -origin.v);
  1608. #endif
  1609.  
  1610.     // ----- Invalid view cached transforms -----
  1611.     PrivInvalidateCachedTransforms(ev);
  1612. }
  1613.  
  1614. #ifdef FW_BUILD_WIN
  1615. //----------------------------------------------------------------------------------------
  1616. //    FW_CFrame::CreateShadowWindow
  1617. //----------------------------------------------------------------------------------------
  1618. // Create a transparent Window so that we get a chance to handle messages sent by Windows
  1619. // controls to their parent Window.
  1620.  
  1621. void FW_CFrame::CreateShadowWindow(Environment *ev)
  1622. {
  1623.     ODPlatformWindow parentHWnd = fWindow->GetPlatformWindow(ev);
  1624. #ifdef FW_BUILD_WIN16
  1625.     HINSTANCE hInstance = (HINSTANCE)GetWindowWord(parentHWnd, GWW_HINSTANCE);
  1626. #endif
  1627. #ifdef FW_BUILD_WIN32
  1628.     HINSTANCE hInstance = (HINSTANCE)GetWindowLong(parentHWnd, GWL_HINSTANCE);
  1629. #endif
  1630.     
  1631.     WNDCLASS wc;
  1632.     
  1633.     if (!GetClassInfo(hInstance, "ShadowWindow", &wc))
  1634.     {
  1635.         wc.style = CS_DBLCLKS;
  1636.         wc.lpfnWndProc = ShadowWindowProc;
  1637.         wc.cbClsExtra = 0;
  1638.         wc.cbWndExtra = 4;
  1639.         wc.hInstance = hInstance;
  1640.         wc.hIcon = NULL;
  1641.         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  1642.         wc.hbrBackground = NULL;
  1643.         wc.lpszMenuName = NULL;
  1644.         wc.lpszClassName = "ShadowWindow";
  1645.         
  1646.         if (!RegisterClass(&wc))
  1647.             return;
  1648.     }
  1649.     
  1650.     fShadowWindow = CreateWindowEx(WS_EX_TRANSPARENT, "ShadowWindow", "",
  1651.                                    WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
  1652.                                    parentHWnd, NULL, hInstance, (LPSTR) this);
  1653.     MoveSizeShadowWindow(ev);
  1654. }
  1655. #endif
  1656.  
  1657. #ifdef FW_BUILD_WIN
  1658. //----------------------------------------------------------------------------------------
  1659. //    FW_CFrame::MoveSizeShadowWindow
  1660. //----------------------------------------------------------------------------------------
  1661.  
  1662. void FW_CFrame::MoveSizeShadowWindow(Environment* ev)
  1663. {
  1664.     if (fShadowWindow != NULL)
  1665.     {
  1666.         ODFacet* facet = GetActiveFacet(ev);
  1667.         FW_CAcquiredODShape aqShape(FW_CopyAndRelease(ev, facet->AcquireActiveShape(ev, NULL)));
  1668.         FW_CAcquiredODTransform aqExternalTransform = facet->AcquireExternalTransform(ev, NULL);
  1669.         aqShape->Transform(ev, aqExternalTransform);
  1670.         
  1671.         FW_CRect bBox;
  1672.         aqShape->GetBoundingBox(ev, &bBox);
  1673.         
  1674.         // Shape bounding box is in 72dpi, need to convert to pixels
  1675.         if(!IsRoot(ev))
  1676.         {
  1677.             // [KVV] ??? This is only necessary for non-root frames
  1678.         
  1679.             HDC hDC = ::GetDC(NULL);
  1680.             int xRes = ::GetDeviceCaps(hDC, LOGPIXELSX);
  1681.             int yRes = ::GetDeviceCaps(hDC, LOGPIXELSY);
  1682.             ::ReleaseDC(NULL, hDC);
  1683.             
  1684.             FW_Fixed xScale = FW_FixDiv(ff(xRes), ff(72));
  1685.             FW_Fixed yScale = FW_FixDiv(ff(yRes), ff(72));
  1686.             
  1687.             bBox.left     = FW_FixMul(bBox.left,    xScale);
  1688.             bBox.top     = FW_FixMul(bBox.top,    yScale);
  1689.             bBox.right     = FW_FixMul(bBox.right,    xScale);
  1690.             bBox.bottom    = FW_FixMul(bBox.bottom,yScale);
  1691.         }
  1692.         
  1693.         FW_PlatformRect wndRect;
  1694.         bBox.AsPlatformRect(wndRect);
  1695.         
  1696.         ::MoveWindow(fShadowWindow, wndRect.left, wndRect.top,
  1697.                        wndRect.right - wndRect.left, wndRect.bottom - wndRect.top, TRUE);
  1698.     }
  1699. }
  1700. #endif
  1701.  
  1702. #ifdef FW_BUILD_WIN
  1703. //----------------------------------------------------------------------------------------
  1704. //    FW_CFrame::ShadowWindowProc
  1705. //----------------------------------------------------------------------------------------
  1706.  
  1707. LRESULT CALLBACK FW_CFrame::ShadowWindowProc(HWND hWnd, UINT msg,
  1708.                                              WPARAM wParam, LPARAM lParam)
  1709. {
  1710.     switch (msg)
  1711.     {
  1712. #ifdef FW_DEBUG
  1713.         // ----- Frame the shadow window for ease of debugging
  1714.         case WM_PAINT:
  1715.             {
  1716.                 PAINTSTRUCT ps;
  1717.                 HDC hDC = ::BeginPaint(hWnd, &ps);
  1718.                 
  1719.                 if(::GetPrivateProfileInt("Debug", "ShadowWindow Outline", FALSE, "ODF.ini"))
  1720.                 {
  1721.                     static const char pattern[8][2] = 
  1722.                     {
  1723.                         { 0xAA, 0x00 },
  1724.                         { 0x55, 0x00 },
  1725.                         { 0xAA, 0x00 },
  1726.                         { 0x55, 0x00 },
  1727.                         { 0xAA, 0x00 },
  1728.                         { 0x55, 0x00 },
  1729.                         { 0xAA, 0x00 },
  1730.                         { 0x55, 0x00 }
  1731.                     };
  1732.                     
  1733.                     HBITMAP hBitmap = ::CreateBitmap(8, 8, 1, 1, pattern);
  1734.     
  1735.                     HBRUSH hBrush = ::CreatePatternBrush(hBitmap);
  1736.     
  1737.                     ::SetTextColor(hDC, RGB(0xFF, 0x00, 0xFF));
  1738.                     
  1739.                     RECT rc;
  1740.                     ::GetClientRect(hWnd, &rc);
  1741.                     
  1742.                     HRGN hRgn = ::CreateRectRgnIndirect(&rc);
  1743.                     
  1744.                     ::FrameRgn(hDC, hRgn, hBrush, 3, 3);
  1745.                     
  1746.                     ::DeleteObject(hRgn);
  1747.                     ::DeleteObject(hBrush);
  1748.                     ::DeleteObject(hBitmap);
  1749.                 }
  1750.  
  1751.                 ::EndPaint(hWnd, &ps);
  1752.             }
  1753.             return 0;
  1754. #endif
  1755.  
  1756.         case WM_CREATE:
  1757.             SetWindowLong(hWnd, 0, (long) ((LPCREATESTRUCT) lParam)->lpCreateParams);
  1758.             return 0;
  1759.             
  1760.         case WM_NCHITTEST:
  1761.             return HTTRANSPARENT;
  1762.             
  1763.         case WM_COMMAND:
  1764.             switch (HIWORD(wParam))
  1765.             {
  1766.                 case BN_CLICKED:
  1767.                     {
  1768.                         HWND hButton = HWND(lParam);
  1769.                         
  1770.                         // If this is a window
  1771.                         if (hButton != NULL && ::IsWindow(hButton))
  1772.                         {
  1773.                             // Get the scroll bar helper
  1774.                             FW_CPrivWinButtonHelper* buttonHelper =
  1775.                                 FW_DYNAMIC_CAST(FW_CPrivWinButtonHelper, FW_CPrivWinControlHelper::HWNDToHelper(hButton));
  1776.         
  1777.                             // Tell the button to update itself and the pane
  1778.                             buttonHelper->HandleButtonMessage();
  1779.                             return 0L;
  1780.                         }
  1781.                     }
  1782.                     break;
  1783.             }
  1784.             break;
  1785.             
  1786.         case WM_HSCROLL:
  1787.         case WM_VSCROLL:
  1788.             {
  1789.                 HWND hBar = HWND(lParam);
  1790.  
  1791.                 // If this is not a scroll bar control, but a Windows
  1792.                 // window scroll bar, pass it to Windows wndproc
  1793.                 if (hBar == NULL)
  1794.                 {
  1795.                     FW_DEBUG_MESSAGE("Warning: ODF does not use Window scroll bars!");
  1796.                     break;
  1797.                 }
  1798.  
  1799.                 // If this is a window
  1800.                 if (hBar != NULL && ::IsWindow(hBar))
  1801.                 {
  1802.                     // Get the scroll bar helper
  1803.                     FW_CPrivWinScrollBarHelper* sbHelper =
  1804.                         FW_DYNAMIC_CAST(FW_CPrivWinScrollBarHelper, FW_CPrivWinControlHelper::HWNDToHelper(hBar));
  1805.  
  1806.                     // Tell the scroll bar to update itself and the pane
  1807.                     if (sbHelper != NULL)
  1808.                     {
  1809.                         sbHelper->HandleScrollMessage(LOWORD(wParam), HIWORD(wParam));
  1810.                         return 0L;
  1811.                     }
  1812.                 }
  1813.                 break;
  1814.             }
  1815.     }
  1816.     
  1817.     return DefWindowProc(hWnd, msg, wParam, lParam);
  1818. }
  1819. #endif
  1820.  
  1821. //----------------------------------------------------------------------------------------
  1822. //    FW_CFrame::HasPropertyOnClipboard
  1823. //----------------------------------------------------------------------------------------
  1824.  
  1825. FW_Boolean FW_CFrame::HasPropertyOnClipboard(Environment* ev, ODPropertyName propertyName, ODValueType type)
  1826. {
  1827.     ODSession* session = GetPart(ev)->GetSession(ev);
  1828.     ODArbitrator* arbitrator = session->GetArbitrator(ev);
  1829.     FW_CAcquiredODFrame aqODFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::gClipboardFocusToken);
  1830.     
  1831.     if ((aqODFrame == fODFrame) || (arbitrator->RequestFocus(ev, FW_CPart::gClipboardFocusToken, fODFrame)) )
  1832.     {    
  1833.         ODStorageUnit* su = session->GetClipboard(ev)->GetContentStorageUnit(ev);
  1834.         return su->Exists(ev, propertyName, type, 0);
  1835.     }
  1836.     else
  1837.     {
  1838.         return FALSE;
  1839.     }
  1840. }
  1841.  
  1842. //----------------------------------------------------------------------------------------
  1843. //    FW_CFrame::PrivContentViewLocationChanged
  1844. //----------------------------------------------------------------------------------------
  1845.  
  1846. void FW_CFrame::PrivContentViewLocationChanged(Environment* ev)
  1847. {
  1848.     FW_CAcquiredODTransform aqViewToFrameTransform = GetContentView(ev)->AcquireViewToFrameTransform(ev);
  1849.     aqViewToFrameTransform->GetOffset(ev, (ODPoint*)&fContentViewLocation);
  1850. }
  1851.  
  1852. //----------------------------------------------------------------------------------------
  1853. //    FW_CFrame::NewPrintHandler
  1854. //----------------------------------------------------------------------------------------
  1855.  
  1856. FW_CPrintHandler* FW_CFrame::NewPrintHandler(Environment* /* ev */)
  1857. {
  1858.     return NULL;
  1859. }
  1860.  
  1861. //----------------------------------------------------------------------------------------
  1862. //    FW_CFrame::IsCurrentlyPrintable
  1863. //----------------------------------------------------------------------------------------
  1864.  
  1865. FW_Boolean FW_CFrame::IsCurrentlyPrintable(Environment* /* ev */) const
  1866. {
  1867.     return TRUE;
  1868. }
  1869.  
  1870. //----------------------------------------------------------------------------------------
  1871. //    FW_CFrame::GetPrintContentExtent
  1872. //----------------------------------------------------------------------------------------
  1873.  
  1874. void FW_CFrame::GetPrintContentExtent(Environment* ev, FW_CPoint& extent) const
  1875. {
  1876.     GetContentExtent(ev, extent);
  1877.     FW_ASSERT(extent.x);
  1878.     FW_ASSERT(extent.y);
  1879. }
  1880.  
  1881. //----------------------------------------------------------------------------------------
  1882. //    FW_CFrame::GetPrintJobTitle
  1883. //----------------------------------------------------------------------------------------
  1884.  
  1885. void FW_CFrame::GetPrintJobTitle(Environment* ev, FW_CString& jobTitle) const
  1886. {
  1887.     GetPart(ev)->GetPartName(ev, jobTitle);
  1888. }
  1889.  
  1890. //========================================================================================
  1891. // CLASS FW_CScrollingViewIterator
  1892. //========================================================================================
  1893.  
  1894. //----------------------------------------------------------------------------------------
  1895. // FW_CScrollingViewIterator::FW_CScrollingViewIterator
  1896. //----------------------------------------------------------------------------------------
  1897.  
  1898. FW_CScrollingViewIterator::FW_CScrollingViewIterator(Environment* ev, const FW_CFrame *container) :
  1899.     fIterator(NULL)    
  1900. {
  1901.     if (container->fScrollingViews)
  1902.         fIterator = new FW_COrderedCollectionIterator(container->fScrollingViews);
  1903.  
  1904.     FW_END_CONSTRUCTOR
  1905. }
  1906.  
  1907. //----------------------------------------------------------------------------------------
  1908. // FW_CScrollingViewIterator::~FW_CScrollingViewIterator
  1909. //----------------------------------------------------------------------------------------
  1910.  
  1911. FW_CScrollingViewIterator::~FW_CScrollingViewIterator()
  1912. {
  1913.     FW_START_DESTRUCTOR
  1914.     
  1915.     delete fIterator;
  1916. }
  1917.